<!Doctype html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<title>SQL语法手册 | 菜鸟教程</title>

  <meta name='robots' content='max-image-preview:large' />
<link rel='stylesheet' id='classic-theme-styles-css' href='../0/classic-themes.min.css?ver=6.2' type='text/css' media='all' />
<link rel="canonical" href="../w3cnote/sql-syntax-manual.html" />
<meta name="keywords" content="SQL语法手册">
<meta name="description" content="Select 用途： 从指定表中取出指定的列的数据。 语法： SELECT column_name(s) FROM table_name 解释： 从数据库中选取指定列，并允许从一或多个指定表中，选取一或多个指定列或指定行。SELECT 陈述式的完整语法相当复杂，但主要子句可摘要为：  SELECT select_list  [ INTO new_table ]  FROM table_source  [ WHERE search_con..">
		
	<link rel="shortcut icon" href="https://static.runoob.com/images/favicon.ico">
	<link rel="stylesheet" href="../0/style.css?v=1.170" type="text/css" media="all" />	
	<link rel="stylesheet" href="../0/font-awesome.min.css" media="all" />	
  <!--[if gte IE 9]><!-->
  <script src=""></script>
  <!--<![endif]-->
  <!--[if lt IE 9]>
     <script src=""></script>
     <script src=""></script>
  <![endif]-->
  <link rel="apple-touch-icon" href="https://static.runoob.com/images/icon/mobile-icon.png"/>
  <meta name="apple-mobile-web-app-title" content="菜鸟教程">
</head>
<body>

<!--  头部 -->
<div class="container logo-search">

  <div class="col search row-search-mobile">
    <form action="index.php">
      <input class="placeholder" placeholder="搜索……" name="s" autocomplete="off">
      
    </form>
  </div>

  <div class="row">
    <div class="col logo">
      <h1><a href="../">菜鸟教程 -- 学的不仅是技术，更是梦想！</a></h1>
    </div>
        <div class="col right-list"> 
    <button class="btn btn-responsive-nav btn-inverse" data-toggle="collapse" data-target=".nav-main-collapse" id="pull" style=""> <i class="fa fa-navicon"></i> </button>
    </div>
        
    <div class="col search search-desktop last">
      <div class="search-input" >
      <form action="//www.runoob.com/" target="_blank">
        <input class="placeholder" id="s" name="s" placeholder="搜索……"  autocomplete="off" style="height: 44px;">
      </form>
      
      </div>
    </div>
  </div>
</div>



<!-- 导航栏 -->
<div class="container navigation">
    <div class="row">
        <div class="col nav">
            

                        <ul class="pc-nav" id="note-nav">
                <li><a href="../">首页</a></li>
                <li><a href="../w3cnote">笔记首页</a></li>
                <li><a href="../w3cnote/android-tutorial-intro.html" title="Android 基础入门教程">Android</a></li>
                <li><a href="../w3cnote/es6-tutorial.html" title="ES6 教程">ES6 教程</a></li>
                <li><a href="../w3cnote/ten-sorting-algorithm.html" title="排序算法">排序算法</a></li>
                <li><a href="../w3cnote/hadoop-tutorial.html" title="Hadoop 教程">Hadoop</a></li>
                <li><a href="../w3cnote/zookeeper-tutorial.html" title="Zookeeper 教程">Zookeeper</a></li>
                <li><a href="../w3cnote/verilog-tutorial.html" title="Verilog 教程">Verilog</a></li>
                <li><a href="../w3cnote_genre/code" title="编程技术">编程技术</a></li> 
                <li><a href="../w3cnote_genre/coderlife" title="程序员人生">程序员人生</a></li>
                
                <!--<li><a href="javascript:;" class="runoob-pop">登录</a></li>
                
                
                        <li>
                <a style="font-weight:bold;" href="../linux/linux-tutorial.html#yunserver" target="_blank" onclick="_hmt.push(['_trackEvent', 'aliyun', 'click', 'aliyun'])" title="kkb">云服务器</a>
                </li>
                <li><a href="http://gk.link/a/104mQ" target="_blank" style="font-weight: bold;"onclick="_hmt.push(['_trackEvent', '极客时间', 'click', 'jike'])" title="我的圈子">极客时间</a></li>
            
                
                <li><a target="_blank" href="../shoppinglist" rel="nofollow">知识店铺</a></li> 
        -->
            </ul>
                        
              
            <ul class="mobile-nav">
                <li><a href="../w3cnote">首页</a></li>
                <li><a href="../w3cnote_genre/android" target="_blank" title="Android 基础入门教程">Android</a></li>
                <li><a href="../w3cnote/es6-tutorial.html" target="_blank" title="ES6 教程">ES6</a></li>
                <li><a href="../w3cnote_genre/joke" target="_blank" title="程序员笑话">逗乐</a></li>
                
                <a href="javascript:void(0)" class="search-reveal">Search</a> 
            </ul>
            
        </div>
    </div>
</div>


<!--  内容  -->
<div class="container main">
	<div class="row">

		<div class="col middle-column big-middle-column">
	 			<div class="article">
			<div class="article-heading">
				<h2>SQL语法手册</h2>				<h3><em>分类</em> <a href="../w3cnote_genre/code" title="编程技术" >编程技术</a> </h3>
			</div>
			<div class="article-body note-body">
				<div class="article-intro">
					<h2>Select</h2>
<p><b>用途：</b></p>
<p>从指定表中取出指定的列的数据。</p>
<p><b>语法：</b></p>
<pre>SELECT column_name(s) FROM table_name</pre>
<p><b>解释：</b></p>
<p>从数据库中选取指定列，并允许从一或多个指定表中，选取一或多个指定列或指定行。SELECT 陈述式的完整语法相当复杂，但主要子句可摘要为：</p>
<pre>
SELECT select_list 
[ INTO new_table ] 
FROM table_source 
[ WHERE search_condition ] 
[ GROUP BY group_by_expression ] 
[ HAVING search_condition ] 
[ ORDER BY order_expression [ ASC | DESC ] ] 
</pre>
<p><b>实例：</b></p>
<p>"Persons" 表中的数据有：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
<td><b>Address</b></td>
<td><b>City</b></td>
</tr>
<tr>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
<tr>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
</tr>
</table>
<p>选出字段名 "LastName"、"FirstName" 的数据：</p>
<pre>SELECT LastName,FirstName FROM Persons</pre>
<p>返回结果：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="50%" bgcolor="#eeeedd" style='width:50.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
</tr>
<tr>
<td>Hansen</td>
<td>Ola</td>
</tr>
<tr>
<td>Svendson</td>
<td>Tove</td>
</tr>
<tr>
<td>Pettersen</td>
<td>Kari</td>
</tr>
</table>
<p>选出所有字段的数据：</p>
<pre>SELECT * FROM Persons</pre>
<p>返回结果：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
<td><b>Address</b></td>
<td><b>City</b></td>
</tr>
<tr>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
<tr>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
</tr>
</table>

<h2>Where</h2>
<p><b>用途：</b></p>
<p>被用来规定一种选择查询的标准。</p>
<p><b>语法：</b></p>
<pre>SELECT column FROM table WHERE column condition value</pre>
<p>下面的操作符能被使用在 WHERE 中：</p>
<p>=,&lt;&gt;,&gt;,&lt;,&gt;=,&lt;=,BETWEEN,LIKE</p>
<p>注意：在某些 SQL 的版本中不等号 &lt; &gt; 能被写作为 != 。</p>
<p><b>解释：</b></p>
<p>SELECT 语句返回 WHERE 子句中条件为 true 的数据。</p>
<p><b>实例：</b></p>
<p>从 "Persons" 表中选出生活在 "Sandnes" 的人：</p>
<pre>SELECT * FROM Persons WHERE City='Sandnes'</pre>
<p>"Persons" 表中的数据有：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
<td><b>Address</b></td>
<td><b>City</b></td>
<td><b>Year</b></td>
</tr>
<tr>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
<td>1951</td>
</tr>
<tr>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
<td>1978</td>
</tr>
<tr>
<td>Svendson</td>
<td>Stale</td>
<td>Kaivn 18</td>
<td>Sandnes</td>
<td>1980</td>
</tr>
<tr>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
<td>1960</td>
</tr>
</table>
<p>返回结果：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
<td><b>Address</b></td>
<td><b>City</b></td>
<td><b>Year</b></td>
</tr>
<tr>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
<td>1951</td>
</tr>
<tr>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
<td>1978</td>
</tr>
<tr>
<td>Svendson</td>
<td>Stale</td>
<td>Kaivn 18</td>
<td>Sandnes</td>
<td>1980</td>
</tr>
</table>

<h2>And &amp; Or</h2>
<p><b>用途：</b></p>
<p>在 WHERE 子句中 AND 和 OR 被用来连接两个或者更多的条件。</p>
<p><b>解释：</b></p>
<p>AND 在结合两个布尔表达式时，只有在两个表达式都为 TRUE 时才传回 TRUE。</p>
<p>OR 在结合两个布尔表达式时，只要其中一个条件为 TRUE 时，OR 便传回 TRUE。</p>
<p><b>实例：</b></p>
<p>"Persons" 表中的原始数据：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
<td><b>Address</b></td>
<td><b>City</b></td>
</tr>
<tr>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
<tr>
<td>Svendson</td>
<td>Stephen</td>
<td>Kaivn 18</td>
<td>Sandnes</td>
</tr>
</table>
<p>用 AND 运算子来查找 "Persons" 表中 FirstName 为 "Tove" 而且 LastName 为 "Svendson" 的数据：</p>
<pre>
SELECT * FROM Persons
WHERE FirstName='Tove'
AND LastName='Svendson'
</pre>
<p>返回结果：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
<td><b>Address</b></td>
<td><b>City</b></td>
</tr>
<tr>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
</table>
<p>用 OR 运算子来查找 "Persons" 表中 FirstName 为 "Tove" 或者 LastName 为 "Svendson" 的数据：</p>
<pre>
SELECT * FROM Persons
WHERE firstname='Tove'
OR lastname='Svendson'
</pre>
<p>返回结果：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
<td><b>Address</b></td>
<td><b>City</b></td>
</tr>
<tr>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
<tr>
<td>Svendson</td>
<td>Stephen</td>
<td>Kaivn 18</td>
<td>Sandnes</td>
</tr>
</table>
<p>你也能结合 AND 和 OR（使用括号形成复杂的表达式），如:</p>
<pre>
SELECT * FROM Persons WHERE
(FirstName='Tove' OR FirstName='Stephen')
AND LastName='Svendson'
</pre>
<p>返回结果：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
<td><b>Address</b></td>
<td><b>City</b></td>
</tr>
<tr>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
<tr>
<td>Svendson</td>
<td>Stephen</td>
<td>Kaivn 18</td>
<td>Sandnes</td>
</tr>
</table>

<h2>Between…And</h2>
<p><b>用途：</b></p>
<p>指定需返回数据的范围。</p>
<p><b>语法：</b></p>
<pre>
SELECT column_name FROM table_name
WHERE column_name
BETWEEN value1 AND value2
</pre>
<p><b>实例：</b></p>
<p>"Persons" 表中的原始数据：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
<td><b>Address</b></td>
<td><b>City</b></td>
</tr>
<tr>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>Nordmann</td>
<td>Anna</td>
<td>Neset 18</td>
<td>Sandnes</td>
</tr>
<tr>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
</tr>
<tr>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
</table>
<p>用 BETWEEN…AND 返回 LastName 为从 "Hansen" 到 "Pettersen" 的数据：</p>
<pre>
SELECT * FROM Persons WHERE LastName 
BETWEEN 'Hansen' AND 'Pettersen'
</pre>
<p>返回结果：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
<td><b>Address</b></td>
<td><b>City</b></td>
</tr>
<tr>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>Nordmann</td>
<td>Anna</td>
<td>Neset 18</td>
<td>Sandnes</td>
</tr>
<tr>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
</tr>
</table>
<p>为了显示指定范围之外的数据，也可以用 NOT 操作符：</p>
<pre>
SELECT * FROM Persons WHERE LastName 
NOT BETWEEN 'Hansen' AND 'Pettersen'
</pre>
<p>返回结果：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
<td><b>Address</b></td>
<td><b>City</b></td>
</tr>
<tr>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
</table>

<h2>Distinct</h2>
<p><b>用途：</b></p>
<p>DISTINCT 关键字被用作返回唯一的值。</p>
<p><b>语法：</b></p>
<pre>SELECT DISTINCT column-name(s) FROM table-name</pre>
<p><b>解释：</b></p>
<p>当 column-name(s) 中存在重复的值时，返回结果仅留下一个。</p>
<p><b>实例：</b></p>
<p>"Orders" 表中的原始数据：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="50%" bgcolor="#eeeedd" style='width:50.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>Company</b></td>
<td><b>OrderNumber</b></td>
</tr>
<tr>
<td>Sega</td>
<td>3412</td>
</tr>
<tr>
<td>RUNOOB</td>
<td>2312</td>
</tr>
<tr>
<td>Trio</td>
<td>4678</td>
</tr>
<tr>
<td>RUNOOB</td>
<td>6798</td>
</tr>
</table>
<p>用 DISTINCT 关键字返回 Company 字段中唯一的值：</p>
<pre>SELECT DISTINCT Company FROM Orders</pre>
<p>返回结果：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="50%" bgcolor="#eeeedd" style='width:50.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>Company</b></td>
</tr>
<tr>
<td>Sega</td>
</tr>
<tr>
<td>RUNOOB</td>
</tr>
<tr>
<td>Trio</td>
</tr>
</table>

<h2>Order by</h2>
<p><b>用途：</b></p>
<p>指定结果集的排序。</p>
<p><b>语法：</b></p>
<pre>SELECT column-name(s) FROM table-name ORDER BY  { order_by_expression [ ASC | DESC ] } </pre>
<p><b>解释：</b></p>
<p>指定结果集的排序，可以按照 ASC（递增方式排序，从最低值到最高值）或者 DESC（递减方式排序，从最高值到最低值）的方式进行排序，默认的方式是 ASC。</p>
<p><b>实例：</b></p>
<p>"Orders" 表中的原始数据：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="50%" bgcolor="#eeeedd" style='width:50.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>Company</b></td>
<td><b>OrderNumber</b></td>
</tr>
<tr>
<td>Sega</td>
<td>3412</td>
</tr>
<tr>
<td>ABC Shop</td>
<td>5678</td>
</tr>
<tr>
<td>RUNOOB</td>
<td>2312</td>
</tr>
<tr>
<td>RUNOOB</td>
<td>6798</td>
</tr>
</table>
<p>按照 Company 字段的升序方式返回结果集：</p>
<pre>
SELECT Company, OrderNumber FROM Orders
ORDER BY Company
</pre>
<p>返回结果：<b>
</b></p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="50%" bgcolor="#eeeedd" style='width:50.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>Company</b></td>
<td><b>OrderNumber</b></td>
</tr>
<tr>
<td>ABC Shop </td>
<td>5678</td>
</tr>
<tr>
<td>Sega</td>
<td>3412</td>
</tr>
<tr>
<td>RUNOOB</td>
<td>6798</td>
</tr>
<tr>
<td>RUNOOB</td>
<td>2312</td>
</tr>
</table>
<p>按照 Company 字段的降序方式返回结果集：</p>
<pre>
SELECT Company, OrderNumber FROM Orders
ORDER BY Company DESC
</pre>
<p>返回结果：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="50%" bgcolor="#eeeedd" style='width:50.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>Company</b></td>
<td><b>OrderNumber</b></td>
</tr>
<tr>
<td>RUNOOB</td>
<td>6798</td>
</tr>
<tr>
<td>RUNOOB</td>
<td>2312</td>
</tr>
<tr>
<td>Sega</td>
<td>3412</td>
</tr>
<tr>
<td>ABC Shop</td>
<td>5678</td>
</tr>
</table>

<h2>Group by</h2>
<p><b>用途：</b></p>
<p>对结果集进行分组，常与汇总函数一起使用。</p>
<p><b>语法：</b></p>
<pre>SELECT column,SUM(column) FROM table GROUP BY column</pre>
<p><b>实例：</b></p>
<p>"Sales" 表中的原始数据：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>Company</b></td>
<td><b>Amount</b></td>
</tr>
<tr>
<td>RUNOOB</td>
<td>5500</td>
</tr>
<tr>
<td>IBM</td>
<td>4500</td>
</tr>
<tr>
<td>RUNOOB</td>
<td>7100</td>
</tr>
</table>
<p>按照 Company 字段进行分组，求出每个 Company 的 Amout 的合计：</p>
<pre>
SELECT Company,SUM(Amount) FROM Sales
GROUP BY Company
</pre>
<p>返回结果：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>Company</b></td>
<td><b>SUM(Amount)</b></td>
</tr>
<tr>
<td>RUNOOB</td>
<td>12600</td>
</tr>
<tr>
<td>IBM</td>
<td>4500</td>
</tr>
</table>

<h2>Having</h2>
<p><b>用途：</b></p>
<p>指定群组或汇总的搜寻条件。</p>
<p><b>语法：</b></p>
<pre>
SELECT column,SUM(column) FROM table
GROUP BY column
HAVING SUM(column) condition value
</pre>
<p><b>解释：</b></p>
<p>HAVING 通常与 GROUP BY 子句同时使用。不使用 GROUP BY 时，HAVING 则与 WHERE 子句功能相似。<b></b></p>
<p><b>实例：</b></p>
<p>"Sales" 表中的原始数据：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>Company</b></td>
<td><b>Amount</b></td>
</tr>
<tr>
<td>RUNOOB</td>
<td>5500</td>
</tr>
<tr>
<td>IBM</td>
<td>4500</td>
</tr>
<tr>
<td>RUNOOB</td>
<td>7100</td>
</tr>
</table>
<p>按照 Company 字段进行分组，求出每个 Company 的 Amout 的合计在 10000 以上的数据：</p>
<pre>
SELECT Company,SUM(Amount) FROM Sales
GROUP BY Company HAVING SUM(Amount)&gt;10000
</pre>
<p>返回结果：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>Company</b></td>
<td><b>SUM(Amount)</b></td>
</tr>
<tr>
<td>RUNOOB</td>
<td>12600</td>
</tr>
</table>

<h2>Join</h2>
<p><b>用途：</b></p>
<p>当你要从两个或者以上的表中选取结果集时，你就会用到 JOIN。</p>
<p><b>实例：</b></p>
<p>"Employees" 表中的数据如下，（其中 ID 为主键）:</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="50%" bgcolor="#eeeedd" style='width:50.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>ID</b></td>
<td><b>Name</b></td>
</tr>
<tr>
<td>01</td>
<td>Hansen, Ola</td>
</tr>
<tr>
<td>02</td>
<td>Svendson, Tove</td>
</tr>
<tr>
<td>03</td>
<td>Svendson, Stephen</td>
</tr>
<tr>
<td>04</td>
<td>Pettersen, Kari</td>
</tr>
</table>
<p>"Orders" 表中的数据如下：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="50%" bgcolor="#eeeedd" style='width:50.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>ID</b></td>
<td><b>Product</b></td>
</tr>
<tr>
<td>01</td>
<td>Printer</td>
</tr>
<tr>
<td>03</td>
<td>Table</td>
</tr>
<tr>
<td>03</td>
<td>Chair</td>
</tr>
</table>
<p>用 Employees 的 ID 和 Orders 的 ID 相关联选取数据：</p>
<pre>
SELECT Employees.Name, Orders.Product
FROM Employees, Orders
WHERE Employees.ID = Orders.ID
</pre>
<p>返回结果：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="50%" bgcolor="#eeeedd" style='width:50.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>Name</b></td>
<td><b>Product</b></td>
</tr>
<tr>
<td>Hansen, Ola</td>
<td>Printer</td>
</tr>
<tr>
<td>Svendson, Stephen</td>
<td>Table</td>
</tr>
<tr>
<td>Svendson, Stephen</td>
<td>Chair</td>
</tr>
</table>
<p>或者你也可以用 JOIN 关键字来完成上面的操作：</p>
<pre>
SELECT Employees.Name, Orders.Product
FROM Employees
INNER JOIN Orders
ON Employees.ID = Orders.ID
</pre>
<p><b>INNER JOIN</b> 的语法：</p>
<pre>
SELECT field1, field2, field3
FROM first_table
INNER JOIN second_table
ON first_table.keyfield = second_table.foreign_keyfield
</pre>
<p><b>解释：</b></p>
<p>INNER JOIN 返回的结果集是两个表中所有相匹配的数据。</p>
<p><b>LEFT JOIN</b> 的语法：</p>
<pre>
SELECT field1, field2, field3
FROM first_table
LEFT JOIN second_table
ON first_table.keyfield = second_table.foreign_keyfield
</pre>
<p>用 "Employees" 表去左外联结 "Orders" 表去找出相关数据：</p>
<pre>
SELECT Employees.Name, Orders.Product
FROM Employees
LEFT JOIN Orders
ON Employees.ID = Orders.ID
</pre>
<p>返回结果：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="50%" bgcolor="#eeeedd" style='width:50.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>Name</b></td>
<td><b>Product</b></td>
</tr>
<tr>
<td>Hansen, Ola</td>
<td>Printer</td>
</tr>
<tr>
<td>Svendson, Tove</td>
<td> </td>
</tr>
<tr>
<td>Svendson, Stephen</td>
<td>Table</td>
</tr>
<tr>
<td>Svendson, Stephen</td>
<td>Chair</td>
</tr>
<tr>
<td>Pettersen, Kari</td>
<td> </td>
</tr>
</table>
<p><b>解释：</b></p>
<p>LEFT JOIN 返回 "first_table" 中所有的行，尽管在 "second_table" 中没有相匹配的数据。</p>
<p><b>RIGHT JOIN</b> 的语法：</p>
<pre>
SELECT field1, field2, field3
FROM first_table
RIGHT JOIN second_table
ON first_table.keyfield = second_table.foreign_keyfield
</pre>
<p>用 "Employees" 表去右外联结 "Orders" 表去找出相关数据：</p>
<pre>
SELECT Employees.Name, Orders.Product
FROM Employees
RIGHT JOIN Orders
ON Employees.ID = Orders.ID
</pre>
<p>返回结果：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="50%" bgcolor="#eeeedd" style='width:50.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td>
<b>Name</b></td>
<td>
<b>Product</b></td>
</tr>
<tr>
<td>Hansen, Ola</td>
<td>Printer</td>
</tr>
<tr>
<td>Svendson, Stephen</td>
<td>Table</td>
</tr>
<tr>
<td>Svendson, Stephen</td>
<td>Chair</td>
</tr>
</table>
<p><b>解释：</b></p>
<p>RIGHT JOIN 返回 "second_table" 中所有的行，尽管在 "first_table" 中没有相匹配的数据。</p>

<h2>Alias</h2>
<p><b>用途：</b></p>
<p>可用在表、结果集或者列上，为它们取一个逻辑名称。</p>
<p><b>语法：</b></p>
<p>给列取别名：</p>
<pre>SELECT column AS column_alias FROM table</pre>
<p>给表取别名：</p>
<pre>SELECT column FROM table AS table_alias</pre>
<p><b>实例：</b></p>
<p>"Persons" 表中的原始数据：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
<td><b>Address</b></td>
<td><b>City</b></td>
</tr>
<tr>
<td>Hansen</td>
<td>Ola</td>
<td>Timoteivn 10</td>
<td>Sandnes</td>
</tr>
<tr>
<td>Svendson</td>
<td>Tove</td>
<td>Borgvn 23</td>
<td>Sandnes</td>
</tr>
<tr>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
</tr>
</table>
<p>运行下面的 SQL：</p>
<pre>
SELECT LastName AS Family, FirstName AS Name
FROM Persons
</pre>
<p>返回结果：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="50%" bgcolor="#eeeedd" style='width:50.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>Family</b></td>
<td><b>Name</b></td>
</tr>
<tr>
<td>Hansen</td>
<td>Ola</td>
</tr>
<tr>
<td>Svendson</td>
<td>Tove</td>
</tr>
<tr>
<td>Pettersen</td>
<td>Kari</td>
</tr>
</table>
<p>运行下面的 SQL：</p>
<pre>
SELECT LastName, FirstName
FROM Persons AS Employees
</pre>
<p>返回结果：</p>
<p>Employees 中的数据有：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="50%" bgcolor="#eeeedd" style='width:50.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
</tr>
<tr>
<td>Hansen</td>
<td>Ola</td>
</tr>
<tr>
<td>Svendson</td>
<td>Tove</td>
</tr>
<tr>
<td>Pettersen</td>
<td>Kari</td>
</tr>
</table>

<h2>Insert Into</h2>
<p><b>用途：</b></p>
<p>在表中插入新行。</p>
<p><b>语法：</b></p>
<p>插入一行数据：</p>
<pre>
INSERT INTO table_name
VALUES (value1, value2,....)
</pre>
<p>插入一行数据在指定的字段上：</p>
<pre>
INSERT INTO table_name (column1, column2,...)
VALUES (value1, value2,....)
</pre>
<p><b>实例：</b></p>
<p>"Persons" 表中的原始数据：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
<td><b>Address</b></td>
<td><b>City</b></td>
</tr>
<tr>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
</tr>
</table>
<p>运行下面的 SQL 插入一行数据：</p>
<pre>
INSERT INTO Persons 
VALUES ('Hetland', 'Camilla', 'Hagabakka 24', 'Sandnes')
</pre>
<p>插入后 "Persons" 表中的数据为：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
<td><b>Address</b></td>
<td><b>City</b></td>
</tr>
<tr>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
</tr>
<tr>
<td>Hetland</td>
<td>Camilla</td>
<td>Hagabakka 24</td>
<td>Sandnes</td>
</tr>
</table>
<p>运行下面的 SQL 插入一行数据在指定的字段上：</p>
<pre>
INSERT INTO Persons (LastName, Address)
VALUES ('Rasmussen', 'Storgt 67')
</pre>
<p>插入后 "Persons" 表中的数据为：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
<td><b>Address</b></td>
<td><b>City</b></td>
</tr>
<tr>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td>Stavanger</td>
</tr>
<tr>
<td>Hetland</td>
<td>Camilla</td>
<td>Hagabakka 24</td>
<td>Sandnes</td>
</tr>
<tr>
<td>Rasmussen</td>
<td> </td>
<td>Storgt 67</td>
<td> </td>
</tr>
</table>

<h2>Update</h2>
<p><b>用途：</b></p>
<p>更新表中原有数据。</p>
<p><b>语法：</b></p>
<pre>
UPDATE table_name SET column_name = new_value
WHERE column_name = some_value
</pre>
<p><b>实例：</b></p>
<p>"Person" 表中的原始数据：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
<td><b>Address</b></td>
<td><b>City</b></td>
</tr>
<tr>
<td>Nilsen</td>
<td>Fred</td>
<td>Kirkegt 56</td>
<td>Stavanger</td>
</tr>
<tr>
<td>Rasmussen</td>
<td> </td>
<td>Storgt 67</td>
<td> </td>
</tr>
</table>
<p>运行下面的 SQL 将 Person 表中 LastName 字段为 "Rasmussen" 的 FirstName 更新为 "Nina"：</p>
<pre>
UPDATE Person SET FirstName = 'Nina'
WHERE LastName = 'Rasmussen'
</pre>
<p>更新后 "Person" 表中的数据为：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
<td><b>Address</b></td>
<td><b>City</b></td>
</tr>
<tr>
<td>Nilsen</td>
<td>Fred</td>
<td>Kirkegt 56</td>
<td>Stavanger</td>
</tr>
<tr>
<td>Rasmussen</td>
<td>Nina</td>
<td>Storgt 67</td>
<td> </td>
</tr>
</table>
<p>同样的，用 UPDATE 语句也可以同时更新多个字段：</p>
<pre>
UPDATE Person
SET Address = 'Stien 12', City = 'Stavanger'
WHERE LastName = 'Rasmussen'
</pre>
<p>更新后 "Person" 表中的数据为：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
<td><b>Address</b></td>
<td><b>City</b></td>
</tr>
<tr>
<td>Nilsen</td>
<td>Fred</td>
<td>Kirkegt 56</td>
<td>Stavanger</td>
</tr>
<tr>
<td>Rasmussen</td>
<td>Nina</td>
<td>Stien 12</td>
<td>Stavanger</td>
</tr>
</table>

<h2>Delete</h2>
<p><b>用途：</b></p>
<p>删除表中的数据。</p>
<p><b>语法：</b></p>
<pre>DELETE FROM table_name WHERE column_name = some_value</pre>
<p><b>实例：</b></p>
<p>"Person" 表中的原始数据：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
<td><b>Address</b></td>
<td><b>City</b></td>
</tr>
<tr>
<td>Nilsen</td>
<td>Fred</td>
<td>Kirkegt 56</td>
<td>Stavanger</td>
</tr>
<tr>
<td>Rasmussen</td>
<td>Nina</td>
<td>Stien 12</td>
<td>Stavanger</td>
</tr>
</table>
<p>删除 Person 表中 LastName 为 "Rasmussen" 的数据：</p>
<pre>DELETE FROM Person WHERE LastName = 'Rasmussen'</pre>
<p>执行删除语句后 "Person" 表中的数据为：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
<td><b>Address</b></td>
<td><b>City</b></td>
</tr>
<tr>
<td>Nilsen</td>
<td>Fred</td>
<td>Kirkegt 56</td>
<td>Stavanger</td>
</tr>
</table>

<h2>创建表 Create Table</h2>
<p><b>用途：</b></p>
<p>建立新的表。</p>
<p><b>语法：</b></p>
<pre>CREATE TABLE table_name 
(
column_name1 data_type, 
column_name2 data_type, 
.......
)</pre>
<p><b>实例：</b></p>
<p>创建一张叫 "Person" 的表，该表有 4 个字段 &quot;LastName&quot;, &quot;FirstName&quot;, &quot;Address&quot;,
&quot;Age&quot;：</p>
<pre>
CREATE TABLE Person 
(
LastName varchar,
FirstName varchar,
Address varchar,
Age int
)
</pre>
<p>如果想指定字段的最大存储长度，你可以这样：</p>
<pre>
CREATE TABLE Person 
(
LastName varchar(30),
FirstName varchar(30),
Address varchar(120),
Age int(3) 
)
</pre>
<p>下表中列出了 SQL 中的一些数据类型：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>数据类型</b></td>
<td><b>描述</b></td>
</tr>
<tr>
<td>integer(size)<br>
int(size)<br>
smallint(size)<br>
tinyint(size)</td>
<td>只存储整数。数字的最大位数由括号内的 size 指定。</td>
</tr>
<tr>
<td>decimal(size,d)<br>
numeric(size,d)</td>
<td>存储带有小数的数字。数字的最大位数由 &quot;size&quot; 指定。小数点右边的最大位数由 &quot;d&quot; 指定。</td>
</tr>
<tr>
<td>char(size)</td>
<td>存储一个固定长度的字符串（可以包含字母、数字和特殊字符）。字符串大小由括号内的 size 指定。</td>
</tr>
<tr>
<td>varchar(size)</td>
<td>存储一个可变长度的字符串（可以包含字母、数字和特殊字符）。字符串的最大长度由括号内的 size 指定。</td>
</tr>
<tr>
<td>date(yyyymmdd)</td>
<td>存储日期。</td>
</tr>
</table>

<h2>修改表 Alter Table</h2>
<p><b>用途：</b></p>
<p>在已经存在的表中增加或者移除字段。</p>
<p><b>语法：</b></p>
<pre>
ALTER TABLE table_name 
ADD column_name datatype
ALTER TABLE table_name 
DROP COLUMN column_name
</pre>
<p>注意：某些数据库管理系统不允许移除表中的字段。</p>
<p><b>实例：</b></p>
<p>"Person" 表中的原始数据：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
<td><b>Address</b></td>
</tr>
<tr>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
</tr>
</table>
<p>在 Person 表中增加一个名为 City 的字段：</p>
<pre>ALTER TABLE Person ADD City varchar(30)</pre>
<p>增加后表中数据如下：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
<td><b>Address</b></td>
<td><b>City</b></td>
</tr>
<tr>
<td>Pettersen</td>
<td>Kari</td>
<td>Storgt 20</td>
<td> </td>
</tr>
</table>
<p>移除 Person 表中原有的 Address 字段：</p>
<pre>ALTER TABLE Person DROP COLUMN Address</pre>
<p>移除后表中数据如下：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>LastName</b></td>
<td><b>FirstName</b></td>
<td><b>City</b></td>
</tr>
<tr>
<td>Pettersen</td>
<td>Kari</td>
<td> </td>
</tr>
</table>

<h2>删除表 Drop Table</h2>
<p><b>用途：</b></p>
<p>在数据库中移除一个数据表定义及该数据表中的所有资料、索引、触发程序、条件约束及权限指定。</p>
<p><b>语法：</b></p>
<pre>DROP TABLE table_name</pre>

<h2>创建数据库 Create Database</h2>
<p><b>用途：</b></p>
<p>建立新的数据库。</p>
<p><b>语法：</b></p>
<pre>CREATE DATABASE database_name</pre>

<h2>删除数据库 Drop Database</h2>
<p><b>用途：</b></p>
<p>移除原有的数据库。</p>
<p><b>语法：</b></p>
<pre>DROP DATABASE database_name</pre>

<h2>聚集函数</h2>

<h3>count</h3>
<p><b>用途：</b></p>
<p>传回选取的结果集中行的数目。</p>
<p><b>语法：</b></p>
<pre>SELECT COUNT(column_name) FROM table_name</pre>
<p><b>实例：</b></p>
<p>"Persons" 表中原始数据如下：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>Name</b></td>
<td><b>Age</b></td>
</tr>
<tr>
<td>Hansen, Ola</td>
<td>34</td>
</tr>
<tr>
<td>Svendson, Tove</td>
<td>45</td>
</tr>
<tr>
<td>Pettersen, Kari</td>
<td>19</td>
</tr>
</table>
<p>选取记录总数：</p>
<pre>SELECT COUNT(Name) FROM Persons</pre>
<p>执行结果：</p>
<pre>3</pre>

<h3>sum</h3>
<p><b>用途：</b></p>
<p>以表达式传回所有值的总和，或仅 DISTINCT 值。SUM 仅可用于数值行。已忽略 Null 值。</p>
<p><b>语法：</b></p>
<pre>SELECT SUM(column_name) FROM table_name</pre>
<p><b>实例：</b></p>
<p>"Persons" 表中原始数据如下：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>Name</b></td>
<td><b>Age</b></td>
</tr>
<tr>
<td>Hansen, Ola</td>
<td>34</td>
</tr>
<tr>
<td>Svendson, Tove</td>
<td>45</td>
</tr>
<tr>
<td>Pettersen, Kari</td>
<td>19</td>
</tr>
</table>
<p>选取 "Persons" 表中所有人的年龄总和：</p>
<pre>SELECT SUM(Age) FROM Persons</pre>
<p>执行结果：</p>
<pre>98</pre>
<p>选取 "Persons" 表中年龄超过 20 岁的人的年龄总和：</p>
<pre>SELECT SUM(Age) FROM Persons WHERE Age&gt;20</pre>
<p>执行结果：</p>
<pre>79</pre>

<h3>avg</h3>
<p><b>用途：</b></p>
<p>传回选取的结果集中值的平均值。已忽略 Null 值。</p>
<p><b>语法：</b></p>
<pre>SELECT AVG(column_name) FROM table_name</pre>
<p><b>实例：</b></p>
<p>"Persons" 表中原始数据如下：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>Name</b></td>
<td><b>Age</b></td>
</tr>
<tr>
<td>Hansen, Ola</td>
<td>34</td>
</tr>
<tr>
<td>Svendson, Tove</td>
<td>45</td>
</tr>
<tr>
<td>Pettersen, Kari</td>
<td>19</td>
</tr>
</table>
<p>选取 "Persons" 表中所有人的平均年龄：</p>
<pre>SELECT AVG(Age) FROM Persons</pre>
<p>执行结果：</p>
<pre>32.67</pre>
<p>选取 "Persons" 表中年龄超过 20 岁的人的平均年龄：</p>
<pre>SELECT AVG(Age) FROM Persons WHERE Age&gt;20</pre>
<p>执行结果：</p>
<pre>39.5</pre>

<h3>max</h3>
<p><b>用途：</b></p>
<p>传回选取的结果集中值的最大值。已忽略 Null 值。</p>
<p><b>语法：</b></p>
<pre>SELECT MAX(column_name) FROM table_name</pre>
<p><b>实例：</b></p>
<p>"Persons" 表中原始数据如下：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>Name</b></td>
<td><b>Age</b></td>
</tr>
<tr>
<td>Hansen, Ola</td>
<td>34</td>
</tr>
<tr>
<td>Svendson, Tove</td>
<td>45</td>
</tr>
<tr>
<td>Pettersen, Kari</td>
<td>19</td>
</tr>
</table>
<p>选取 "Persons" 表中的最大年龄：</p>
<pre>SELECT MAX(Age) FROM Persons</pre>
<p>执行结果：</p>
<pre>45</pre>

<h3>min</h3>
<p><b>用途：</b></p>
<p>传回选取的结果集中值的最小值。已忽略 Null 值。</p>
<p><b>语法：</b></p>
<pre>SELECT MIN(column_name) FROM table_name</pre>
<p><b>实例：</b></p>
<p>"Persons" 表中原始数据如下：</p>
<table style="table-layout:fixed;word-wrap:break-word;word-break;break-all;" border=1 cellspacing=0 cellpadding=0 width="100%" bgcolor="#eeeedd" style='width:100.0%;mso-cellspacing:0cm;background:#EEEEDD'>
<tr>
<td><b>Name</b></td>
<td><b>Age</b></td>
</tr>
<tr>
<td>Hansen, Ola</td>
<td>34</td>
</tr>
<tr>
<td>Svendson, Tove</td>
<td>45</td>
</tr>
<tr>
<td>Pettersen, Kari</td>
<td>19</td>
</tr>
</table>
<p>选取 "Persons" 表中的最小年龄：</p>
<pre>SELECT MIN(Age) FROM Persons</pre>
<p>执行结果：</p>
<pre>19</pre>

<h2>算术函数</h2>

<h3>abs</h3>
<p><b>用途：</b></p>
<p>传回指定数值表达式（Numeric Expression）的绝对正值。</p>
<p><b>语法：</b></p>
<pre>ABS(numeric_expression )</pre>
<p><b>实例：</b></p>
<pre>ABS(-1.0) ABS(0.0) ABS(1.0)</pre>
<p>执行结果：</p>
<pre>1.0         0.0        1.0</pre>

<h3>ceil</h3>
<p><b>用途：</b></p>
<p>传回大于等于给定数值表达式的最小整数。</p>
<p><b>语法：</b></p>
<pre>CEIL(numeric_expression )</pre>
<p><b>实例：</b></p>
<pre>CEIL(123.45)   CEIL(-123.45)</pre>
<p>执行结果：</p>
<pre>124.00            -123.00</pre>

<h3>floor</h3>
<p><b>用途：</b></p>
<p>传回小于或等于给定数值表达式的最大整数。</p>
<p><b>语法：</b></p>
<pre>FLOOR(numeric_expression )</pre>
<p><b>实例：</b></p>
<pre>FLOOR(123.45)   FLOOR(-123.45)</pre>
<p>执行结果：</p>
<pre>123.00             -124.00</pre>

<h3>cos</h3>
<p><b>用途：</b></p>
<p>在指定表达式中传回指定角度（以弪度为单位）的三角余弦值的数学函数。</p>
<p><b>语法：</b></p>
<pre>COS(numeric_expression )</pre>
<p><b>实例：</b></p>
<pre>COS(14.78)</pre>
<p>执行结果：</p>
<pre>-0.599465</pre>

<h3>cosh</h3>
<p><b>用途：</b></p>
<p>传回以弧度为单位的角度值，其余弦为指定的 float 表达式，也称为反余弦。</p>
<p><b>语法：</b></p>
<pre>COSH(numeric_expression )</pre>
<p><b>实例：</b></p>
<pre>COSH(-1)</pre>
<p>执行结果：</p>
<pre>3.14159</pre>

<h3>sin</h3>
<p><b>用途：</b></p>
<p>以近似的数值（float）表达式传回给定角度（弧度）的三角正弦函数。</p>
<p><b>语法：</b></p>
<pre>SIN(numeric_expression )</pre>
<p><b>实例：</b></p>
<pre>SIN(45.175643)</pre>
<p>执行结果：</p>
<pre>0.929607</pre>

<h3>sinh</h3>
<p><b>用途：</b></p>
<p>传回以弪度为单位的角度，其正弦为指定的 float 表达式，也称为反正弦。</p>
<p><b>语法：</b></p>
<pre>SINH(numeric_expression )</pre>
<p><b>实例：</b></p>
<pre>SINH(-1.00)</pre>
<p>执行结果：</p>
<pre>-1.5708</pre>

<h3>tan</h3>
<p><b>用途：</b></p>
<p>传回输入表达式的正切函数。</p>
<p><b>语法：</b></p>
<pre>TAN(numeric_expression )</pre>
<p><b>实例：</b></p>
<pre>TAN(3.14159265358979/2)</pre>
<p>执行结果：</p>
<pre>1.6331778728383844E+16</pre>

<h3>tanh</h3>
<p><b>用途：</b></p>
<p>传回以弪度为单位的角度，其正切为指定的 float 表达式，也称为反正切。</p>
<p><b>语法：</b></p>
<pre>TANH(numeric_expression )</pre>
<p><b>实例：</b></p>
<pre>TANH(-45.01)</pre>
<p>执行结果：</p>
<pre>-1.54858</pre>

<h3>exp</h3>
<p><b>用途：</b></p>
<p>传回给定的 float 表达式的指数（Exponential）值。</p>
<p><b>语法：</b></p>
<pre>EXP(numeric_expression )</pre>
<p><b>实例：</b></p>
<pre>EXP(378.615345498)</pre>
<p>执行结果：</p>
<pre>2.69498e+164 </pre>

<h3>log</h3>
<p><b>用途：</b></p>
<p>传回给定的 float 表达式的自然对数。</p>
<p><b>语法：</b></p>
<pre>LOG(numeric_expression )</pre>
<p><b>实例：</b></p>
<pre>LOG(5.175643)</pre>
<p>执行结果：</p>
<pre>1.64396 </pre>

<h3>power</h3>
<p><b>用途：</b></p>
<p>传回给定表达式的指定乘幂的值。</p>
<p><b>语法：</b></p>
<pre>POWER(numeric_expression,v )</pre>
<p><b>实例：</b></p>
<pre>POWER(2,6)</pre>
<p>执行结果：</p>
<pre>64</pre>

<h3>sign</h3>
<p><b>用途：</b></p>
<p>传回给定表达式的正（+1）、零（0）或负（-1）号。</p>
<p><b>语法：</b></p>
<pre>SIGN(numeric_expression )</pre>
<p><b>实例：</b></p>
<pre>SIGN(123)    SIGN(0)    SIGN(-456)</pre>
<p>执行结果：</p>
<pre>1             0          -1</pre>

<h3>sqrt</h3>
<p><b>用途：</b></p>
<p>传回给定表达式的平方。</p>
<p><b>语法：</b></p>
<pre>SQRT(numeric_expression )</pre>
<p><b>实例：</b></p>
<pre>SQRT(10)</pre>
<p>执行结果：</p>
<pre>100</pre>

<h2>更多教程</h2>
<p>更详细教程可参考：<a href="../sql/sql-tutorial.html" title="SQL 教程">SQL 教程</a></p>				</div>
			</div>
			<div class="previous-next-links">
			<div class="previous-design-link">← <a href="../w3cnote/php-array-operation.html" rel="prev"> PHP数组操作详解</a> </div>
			<div class="next-design-link"><a href="../w3cnote/code-comment.html" rel="next"> 代码注释中的5要与3不要</a> →</div>
			</div>
			<style>
.wrapper {
  /*text-transform: uppercase; */
  background: #ececec;
  color: #555;
  cursor: help;
  font-family: "Gill Sans", Impact, sans-serif;
  font-size: 20px;
  position: relative;
  text-align: center;
  width: 200px;
  -webkit-transform: translateZ(0); /* webkit flicker fix */
  -webkit-font-smoothing: antialiased; /* webkit text rendering fix */
}

.wrapper .tooltip {
  white-space: nowrap;
  font-size: 14px;
  text-align: left;
  background: #96b97d;
  bottom: 100%;
  color: #fff;
  display: block;
  left: -25px;
  margin-bottom: 15px;
  opacity: 0;
  padding: 14px;
  pointer-events: none;
  position: absolute;
  
  -webkit-transform: translateY(10px);
     -moz-transform: translateY(10px);
      -ms-transform: translateY(10px);
       -o-transform: translateY(10px);
          transform: translateY(10px);
  -webkit-transition: all .25s ease-out;
     -moz-transition: all .25s ease-out;
      -ms-transition: all .25s ease-out;
       -o-transition: all .25s ease-out;
          transition: all .25s ease-out;
  -webkit-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
     -moz-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
      -ms-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
       -o-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
          box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
}
.tooltip a {
	color:#fff;
}
/* This bridges the gap so you can mouse into the tooltip without it disappearing */
.wrapper .tooltip:before {
  bottom: -20px;
  content: " ";
  display: block;
  height: 20px;
  left: 0;
  position: absolute;
  width: 100%;
}  

/* CSS Triangles - see Trevor's post */
.wrapper .tooltip:after {
  border-left: solid transparent 10px;
  border-right: solid transparent 10px;
  border-top: solid #96b97d 10px;
  bottom: -10px;
  content: " ";
  height: 0;
  left: 20%;
  margin-left: -13px;
  position: absolute;
  width: 0;
}
.wrapper .tooltip1 {
	margin-left: 50px;
	padding-top: 0px;
}
/*
.wrapper:hover .tooltip {
  opacity: 1;
  pointer-events: auto;
  -webkit-transform: translateY(0px);
     -moz-transform: translateY(0px);
      -ms-transform: translateY(0px);
       -o-transform: translateY(0px);
          transform: translateY(0px);
}
*/
/* IE can just show/hide with no transition */
.lte8 .wrapper .tooltip {
  display: none;
}

.lte8 .wrapper:hover .tooltip {
  display: block;
}

</style>

<link rel="stylesheet" href="../0/upvotejs.css">
<script src=""></script>
<script src=""></script>
<div id="respond" class="no_webshot"> 
		<div class="comment-signarea" style=" padding: 20px 20px;"> 
	<h3 class="text-muted" id="share_code" style="color: #799961;"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> 点我分享笔记</h3>
	<!--
	<p style="font-size:14px;">笔记需要是本篇文章的内容扩展！</p><br>
	<p style="font-size:12px;"><a href="../tougao" target="_blank">文章投稿，可点击这里</a></p>
	<p style="font-size:14px;"><a href="../w3cnote/runoob-user-test-intro.html#invite" target="_blank">注册邀请码获取方式</a></p>
		<h3 class="text-muted"><i class="fa fa-info-circle" aria-hidden="true"></i> 分享笔记前必须<a href="javascript:;" class="runoob-pop">登录</a>！</h3>
		<p><a href="../w3cnote/runoob-user-test-intro.html#invite" target="_blank">注册邀请码获取方式</a></p>-->
	</div>
		
	<form action="/wp-content/themes/runoob/option/addnote.php" method="post" id="commentform" style="display:none;">
		<div class="comt">
			<div class="comt-title">
				<i style="font-size:36px;" class="fa fa-user-circle" aria-hidden="true"></i>				<p><a id="cancel-comment-reply-link" href="javascript:;">取消</a></p>
			</div>
			<div class="comt-box">
			<div id="mded"></div>
			
				<div class="comt-ctrl">
					<div class="comt-tips"><input type='hidden' name='comment_post_ID' value='12103' id='comment_post_ID' />
<input type='hidden' name='comment_parent' id='comment_parent' value='0' />
</div>
					<button type="submit" name="submit" id="submit" tabindex="5"><i class="fa fa-pencil" aria-hidden="true"></i> 分享笔记</button>
				</div>
			</div>
		
				
					<div class="comt-comterinfo"> 
						<ul id="comment-author-info">
							<li class="form-inline"><label class="hide" for="author">昵称</label><input class="ipt" type="text" name="author" id="author" value="" tabindex="2" placeholder="昵称"><span class="text-muted">昵称 (必填)</span></li>
							<li class="form-inline"><label class="hide" for="email">邮箱</label><input class="ipt" type="text" name="email" id="email" value="" tabindex="3" placeholder="邮箱"><span class="text-muted">邮箱 (必填)</span></li>
							<li class="form-inline"><label class="hide" for="url">引用地址</label><input class="ipt" type="text" name="url" id="url" value="" tabindex="4" placeholder="引用地址"><span class="text-muted">引用地址</span></li>
						</ul>
					</div>
				
			
		</div>

	</form>
	</div>
<script type="text/javascript">
$(function() {
	//初始化编辑器
	
	var editor = new Simditor({
	  textarea: $('#mded'),
	  placeholder: '写笔记...',
	  upload:false,
	 // upload: {url:'/api/comment_upload_file.php',params: null,fileKey: 'upload_file',connectionCount: 1,leaveConfirm: '文件正在上传，您确定离开?'},
	  defaultImage: 'https://www.runoob.com/images/logo.png',
	  codeLanguages: '',
	  autosave: 'editor-content',
	  toolbar: [  'bold','code','ul','ol','image' ]
	});
	editor.on('selectionchanged', function() {
		$(".code-popover").hide();
	});

	// 提交数据
	$("#share_code").click(function() {
		$(".comment-signarea").hide();
		$("#commentform").show();
		
	});
	$("#user_add_note").click(function() {
		$(".comment-signarea").hide();
		$("#commentform").show();
		$('html, body').animate({
       	    scrollTop: $("#respond").offset().top
    	}, 200);
	});

	// 提交笔记
	var commentform=$('#commentform');
	commentform.prepend('<div id="comment-status" style="display:none;" ></div>');
	var statusdiv=$('#comment-status');
	
	commentform.submit(function(e){
		e.preventDefault();
		var noteContent = editor.getValue();
		// console.log(noteContent);
		noteContent = noteContent.replace(/<pre><code>/g,"<pre>");
		noteContent = noteContent.replace(/<\/code><\/pre>/g,"</pre>");
		
		// 系列化表单数据
		var comment_parent = 0;
		var is_user_logged_in = $("#is_user_logged_in").val();
		var comment_post_ID =  12103;
		var _wp_unfiltered_html_comment = $("#_wp_unfiltered_html_comment").val();
		var comment = noteContent;
		var author = $("#author").val();
		var url = $("#url").val();
		var email = $("#email").val();
		if(isBlank(author) && is_user_logged_in==0) {
			statusdiv.html('<p  class="ajax-error">请输入昵称！</p>').show();
		} else if(isBlank(email)  && is_user_logged_in==0) {
			statusdiv.html('<p  class="ajax-error">请输入邮箱！</p>').show();
		} else {
			// var formdata=commentform.serialize() + "&comment=" + noteContent ;
			// 添加状态信息
			statusdiv.html('<p>Processing...</p>').show();
			// 获取表单提交地址
			var formurl=commentform.attr('action');
			
			// 异步提交
			$.ajax({
					type: 'post',
					url: formurl,
					dataType:'json',
					data: {"comment_parent":comment_parent,"comment_post_ID":comment_post_ID, "_wp_unfiltered_html_comment":_wp_unfiltered_html_comment,"comment":comment,"url":url, "email":email,"author":author},
					error: function(XMLHttpRequest, textStatus, errorThrown){
					statusdiv.html('<p class="ajax-error" >数据不完整或表单提交太快了！</p>').show();
				},
				success: function(data, textStatus){
					if(data.errorno=="0") {
						$("#submit").prop('disabled', true);
						statusdiv.html('<p class="ajax-success" >笔记已提交审核，感谢分享笔记！</p>').show();
						alert('笔记已提交审核，感谢分享笔记！');
					}else{
						statusdiv.html('<p class="ajax-error" >'+data.msg+'</p>').show();
					}
					commentform.find('textarea[name=comment]').val('');
				}
			});
			setTimeout(function(){
		        $("#submit").prop('disabled', false);
		    }, 10*1000);
		}
		return false;

	});
	$(".comt-author").click(function() {
		href = $(this).children("a").attr("href");
		if(href.indexOf("/note/")!=-1) {
			var win = window.open(href, '_blank');
  			win.focus();
		}
	});
	$(".comt-meta span").hover(function(){
		$(this).children(".tooltip").css({ "opacity": 1, "pointer-events": "auto"});
	},function(){
		$(this).children(".tooltip").removeAttr("style");
	});
	/*
	$(".wrapper i").hover(function(){
		$(this).siblings(".tooltip").css({ "opacity": 1, "pointer-events": "auto"});
	},function(){
		$(this).siblings(".tooltip").css({ "opacity": 0, "pointer-events": "auto"});
	});
	*/
	//Upvote.create('runoobvote-id', {callback: vote_callback});
	var ajaxurl = 'https://www.runoob.com/wp-admin/admin-ajax.php';
	var callback = function(data) {
		//console.log($('#runoobvote-id').upvote('upvoted'));
		//console.log($('#runoobvote-id').upvote('downvoted'));
		//console.log(data);
		_vote_action = data.action;
		id_arr = data.id.split('-');
		um_id= id_arr[2];
		//console.log(um_id);
		
		var re = /^[1-9]+/;
		if (re.test(um_id)) { 
			var ajax_data = {
				_vote_action: _vote_action,
				action: "pinglun_zan",
				um_id: um_id,
				um_action: "ding"
			};
			//console.log(ajax_data);
			$.post(ajaxurl,ajax_data,function(status){
				//if(status.vote_num>999) {
				//	_voteHtml = '<span style="display: block; text-align: center;font-size: 20px; color: #6a737c; margin: 8px 0;">'+kFormatter(status.vote_num) +'</span>';
				//	$("#runoobvote-id-" + um_id + " .count").hide().after(_voteHtml);
				//}
				
			});
		}
	};
	if($('#comments').length && $('.upvotejs').length){
		$('.upvotejs').upvote({id: 12103, callback: callback});
	
		$.post(ajaxurl,{"action":"pinglun_zan","postid":12103},function(data){  
			$(data).each(function(key,value) {
				$("#runoobvote-id-" + value.commid + " .upvote").addClass(value.upvotejs_class);
				$("#runoobvote-id-" + value.commid + " .downvote").addClass(value.downvote_class);
				$("#runoobvote-id-" + value.commid + " .count").text(value.upvote_count);
			})
		},'json');
		
	}
	
	
});
function isBlank(str) {
    return (!str || /^\s*$/.test(str));
}
function kFormatter(num) {
	// return num;
    return Math.abs(num) > 999 ? Math.sign(num)*((Math.abs(num)/1000).toFixed(1)) + 'k' : Math.sign(num)*Math.abs(num)
}

</script>

<link rel="stylesheet" href="../0/qa.css?1.44">
<link rel="stylesheet" type="text/css" href="../0/simditor.min.css" />
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
			<div class="article-heading-ad" id="w3cnote-ad728">
			<script async src=""></script>
			<!-- 移动版 自动调整 -->
			<ins class="adsbygoogle"
			     style="display:inline-block;min-width:300px;max-width:970px;width:100%;height:90px"
			     data-ad-client="ca-pub-5751451760833794"
			     data-ad-slot="1691338467"
			     data-ad-format="horizontal"></ins>
			<script>
			(adsbygoogle = window.adsbygoogle || []).push({});
			</script>
			</div>
			<style>
@media screen and (max-width: 768px) {
	#w3cnote-ad728 {
		display: none;
	}
}
p.note-author {
    border-bottom: 1px solid #ddd;
    font-size: 18px;
    font-weight: bold;
    color: #78a15a;
    padding-bottom: 2px;
    margin-bottom: 4px;
}
</style>
<script>
var aid = 12103;
</script>
	</div>
		
	</div>
	<div class="listcol last right-column">




<!--
	<div class="tab tab-light-blue"> 订阅</div>
	<div class="sidebar-box">
		<div class="socialicons">
			<a href="../feed" class="rss">RSS 订阅</a>
		
			<form action="//list.qq.com/cgi-bin/qf_compose_send" method="post">
			<input type="hidden" value="qf_booked_feedback" name="t">
			<input type="hidden" value="4b67b6b6c1f5e792559940cab4aebb8f1126fba880bff1a8" name="id">
			<input class="placeholder" id="feed_email" name="to" value="输入邮箱 订阅笔记" autocomplete="off">
			<input type="submit" value="订阅" class="btn btn-primary">
			</form>
		
		</div>
 
	</div>
-->	



<!--
	<div class="sidebar-box cate-list">
	<div class="sidebar-box recommend-here list-link">
			<a href="javascript:void(0);" style="font-size: 16px; color:#64854c;font-weight:bold;">笔记列表</a>
		</div>

 

</div>
-->

	 <div class="sidebar-box cate-list">
		 		

	 	<div class="sidebar-box recommend-here list-link">
			<a href="javascript:void(0);" style="font-size: 16px; color:#64854c;font-weight:bold;">教程列表</a>
		</div>
		
		<div class="cate-items"> 
				<a href="../ado">ADO 教程</a>
	<a href="../ajax">Ajax 教程</a>
	<a href="../android">Android 教程</a>
	<a href="../angularjs2">Angular2 教程</a>
	<a href="../angularjs">AngularJS 教程</a>
	<a href="../appml">AppML 教程</a>
	<a href="../asp">ASP 教程</a>
	<a href="../aspnet">ASP.NET 教程</a>
	<a href="../bootstrap">Bootstrap 教程</a>
	<a href="../bootstrap4">Bootstrap4 教程</a>
	<a href="../bootstrap5">Bootstrap5 教程</a>
	<a href="../cprogramming">C 教程</a>
	<a href="../csharp">C# 教程</a>
	<a href="../cplusplus">C++ 教程</a>
	<a href="../chartjs">Chart.js 教程</a>
	<a href="../cssref">CSS 参考手册</a>
	<a href="../css">CSS 教程</a>
	<a href="../css3">CSS3 教程</a>
	<a href="../django">Django 教程</a>
	<a href="../docker">Docker 教程</a>
	<a href="../dtd">DTD 教程</a>
	<a href="../echarts">ECharts 教程</a>
	<a href="../eclipse">Eclipse 教程</a>
	<a href="../firebug">Firebug 教程</a>
	<a href="../font-awesome">Font Awesome 图标</a>
	<a href="../foundation">Foundation 教程</a>
	<a href="../git">Git 教程</a>
	<a href="../go">Go 语言教程</a>
	<a href="../googleapi">Google 地图 API 教程</a>
	<a href="../highcharts">Highcharts 教程</a>
	<a href="../htmldom">HTML DOM 教程</a>
	<a href="../tags">HTML 参考手册</a>
	<a href="../charsets">HTML 字符集</a>
	<a href="../html">HTML 教程</a>
	<a href="../http">HTTP 教程</a>
	<a href="../ionic">ionic 教程</a>
	<a href="../ios">iOS 教程</a>
	<a href="../java">Java 教程</a>
	<a href="../jsref">JavaScript 参考手册</a>
	<a href="../js">Javascript 教程</a>
	<a href="../jeasyui">jQuery EasyUI 教程</a>
	<a href="../jquerymobile">jQuery Mobile 教程</a>
	<a href="../jqueryui">jQuery UI 教程</a>
	<a href="../jquery">jQuery 教程</a>
	<a href="../json">JSON 教程</a>
	<a href="../jsp">JSP 教程</a>
	<a href="../julia">Julia 教程</a>
	<a href="../kotlin">Kotlin 教程</a>
	<a href="../linux">Linux 教程</a>
	<a href="../lua">Lua 教程</a>
	<a href="../markdown">Markdown 教程</a>
	<a href="../matplotlib">Matplotlib 教程</a>
	<a href="../maven">Maven 教程</a>
	<a href="../memcached">Memcached 教程</a>
	<a href="../mongodb">MongoDB 教程</a>
	<a href="../mysql">MySQL 教程</a>
	<a href="../nodejs">Node.js 教程</a>
	<a href="../numpy">NumPy 教程</a>
	<a href="../pandas">Pandas 教程</a>
	<a href="../perl">Perl 教程</a>
	<a href="../php">PHP 教程</a>
	<a href="../postgresql">PostgreSQL 教程</a>
	<a href="../python3">Python 3 教程</a>
	<a href="../python">Python 基础教程</a>
	<a href="../r">R 教程</a>
	<a href="../rdf">RDF 教程</a>
	<a href="../react">React 教程</a>
	<a href="../redis">Redis 教程</a>
	<a href="../rss">RSS 教程</a>
	<a href="../ruby">Ruby 教程</a>
	<a href="../rust">Rust 教程</a>
	<a href="../sass">Sass 教程</a>
	<a href="../scala">Scala 教程</a>
	<a href="../scipy">SciPy 教程</a>
	<a href="../servlet">Servlet 教程</a>
	<a href="../soap">SOAP 教程</a>
	<a href="../sql">SQL 教程</a>
	<a href="../sqlite">SQLite 教程</a>
	<a href="../svg">SVG 教程</a>
	<a href="../svn">SVN 教程</a>
	<a href="../swift">Swift 教程</a>
	<a href="../tcpip">TCP/IP 教程</a>
	<a href="../typescript">TypeScript 教程</a>
	<a href="../vbscript">VBScript 教程</a>
	<a href="../vue2">Vue.js 教程</a>
	<a href="../vue3">Vue3 教程</a>
	<a href="../w3c">W3C 教程</a>
	<a href="../webservices">Web Service 教程</a>
	<a href="../wsdl">WSDL 教程</a>
	<a href="../xlink">XLink 教程</a>
	<a href="../dom">XML DOM 教程</a>
	<a href="../schema">XML Schema 教程</a>
	<a href="../xml">XML 教程</a>
	<a href="../xpath">XPath 教程</a>
	<a href="../xquery">XQuery 教程</a>
	<a href="../xslfo">XSLFO 教程</a>
	<a href="../xsl">XSLT 教程</a>
	<a href="../data-structures">数据结构</a>
	<a href="../regexp">正则表达式</a>
	<a href="../quiz">测验</a>
	<a href="../browsers">浏览器</a>
	<a href="../quality">网站品质</a>
	<a href="../web">网站建设指南</a>
	<a href="../hosting">网站服务器教程</a>
	<a href="../design-pattern">设计模式</a>
			
		</div> 
		 	 </div>
</div>
	</div>
</div>


<!-- 底部 -->
<div id="footer" class="mar-t50">
   <div class="runoob-block">
    <div class="runoob cf">
     <dl>
      <dt>
       在线实例
      </dt>
      <dd>
       &middot;<a target="_blank" href="../html/html-examples.html">HTML 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../css/css-examples.html">CSS 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../js/js-examples.html">JavaScript 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../ajx/ajax-examples.html">Ajax 实例</a>
      </dd>
       <dd>
       &middot;<a target="_blank" href="../jquery/jquery-examples.html">jQuery 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../xml/xml-examples.html">XML 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../java/java-examples.html">Java 实例</a>
      </dd>
     
     </dl>
     <dl>
      <dt>
      字符集&工具
      </dt>
      <dd>
       &middot; <a target="_blank" href="../charsets/html-charsets.html">HTML 字符集设置</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="../tags/html-ascii.html">HTML ASCII 字符集</a>
      </dd>
     <dd>
       &middot; <a target="_blank" href="https://c.runoob.com/front-end/6939/">JS 混淆/加密</a>
      </dd> 
      <dd>
       &middot; <a target="_blank" href="https://c.runoob.com/front-end/6232/">PNG/JPEG 图片压缩</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="../tags/html-colorpicker.html">HTML 拾色器</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="..//c.runoob.com/front-end/53">JSON 格式化工具</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="..//c.runoob.com/front-end/6680/">随机数生成器</a>
      </dd>
     </dl>
     <dl>
      <dt>
       最新更新
      </dt>
                   <dd>
       &middot;
      <a href="../matplotlib/matplotlib-imread.html" title="Matplotlib imread() 方法">Matplotlib imre...</a>
      </dd>
              <dd>
       &middot;
      <a href="../matplotlib/matplotlib-imsave.html" title="Matplotlib imsave() 方法">Matplotlib imsa...</a>
      </dd>
              <dd>
       &middot;
      <a href="../matplotlib/matplotlib-imshow.html" title="Matplotlib imshow() 方法">Matplotlib imsh...</a>
      </dd>
              <dd>
       &middot;
      <a href="../matplotlib/matplotlib-hist.html" title="Matplotlib 直方图">Matplotlib 直方图</a>
      </dd>
              <dd>
       &middot;
      <a href="../python3/python-func-object.html" title="Python object() 函数">Python object()...</a>
      </dd>
              <dd>
       &middot;
      <a href="../python3/python-ai-draw.html" title="Python AI 绘画">Python AI 绘画</a>
      </dd>
              <dd>
       &middot;
      <a href="../w3cnote/cursor-editor.html" title="神辅助 Cursor 编辑器，加入 GPT-4 让编码更轻松！">神辅助 Cursor ...</a>
      </dd>
             </dl>
     <dl>
      <dt>
       站点信息
      </dt>
      <dd>
       &middot;
       <a target="_blank" href="mailto:admin@runoob.com" rel="external nofollow">意见反馈</a>
       </dd>
      <dd>
       &middot;
      <a target="_blank" href="../disclaimer">免责声明</a>
       </dd>
      <dd>
       &middot;
       <a target="_blank" href="../aboutus">关于我们</a>
       </dd>
      <dd>
       &middot;
      <a target="_blank" href="../archives">文章归档</a>
      </dd>
    
     </dl>
    
     <div class="search-share">
      <div class="app-download">
        <div>
         <strong>关注微信</strong>
        </div>
      </div>
      <div class="share">
      <img width="128" height="128" src="/wp-content/themes/runoob/assets/images/qrcode.png" />
       </div>
     </div>
     
    </div>
   </div>
   <div class="w-1000 copyright">
     Copyright &copy; 2013-2023    <strong><a href="../" target="_blank">菜鸟教程</a></strong>&nbsp;
    <strong><a href="../" target="_blank">runoob.com</a></strong> All Rights Reserved. 备案号：<a target="_blank" rel="nofollow" href="https://beian.miit.gov.cn/">闽ICP备15012807号-1</a>
   </div>
  </div>
  <div class="fixed-btn">
    <a class="go-top" href="javascript:void(0)" title="返回顶部"> <i class="fa fa-angle-up"></i></a>
    <a class="qrcode"  href="javascript:void(0)" title="关注我们"><i class="fa fa-qrcode"></i></a>
    <a class="writer" style="display:none" href="javascript:void(0)"   title="标记/收藏"><i class="fa fa-star" aria-hidden="true"></i></a>
    <!-- qrcode modal -->
    <div id="bottom-qrcode" class="modal panel-modal hide fade in">
      <h4>微信关注</h4>
      <div class="panel-body"><img alt="微信关注" width="128" height="128" src="/wp-content/themes/runoob/assets/images/qrcode.png"></div> 
    </div>
  </div>

 <div style="display:none;">
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-84264393-2"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-84264393-2');
</script>
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?3eec0b7da6548cf07db3bc477ea905ee";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

</div>
<script>
window.jsui={
    www: 'https://www.runoob.com',
    uri: 'https://www.runoob.com/wp-content/themes/runoob'
};
</script>

<script src=""></script>
<script src=""></script>

</body>
</html>